/**********************************************************************
 * SailmiPIM - modular cross-platform feature rich internet client.
 * Copyright (C) 2006-2014  Georg Rudoy
 *
 * Distributed under the Boost Software License, Version 1.0.
 * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
 **********************************************************************/

#pragma once

#include <memory>
#include <QWebEnginePage>
#include <sailmipim/core/ihookproxy.h>
#include <sailmipim/browser/iwebview.h>
#include <sailmipim/browser/ilinkopenmodifier.h>
#include <sailmipim/browser/iwebviewprovider.h>

namespace SailmiPIM::Plugin::Browser
{
class IProxyObject;

namespace WebEngineView
{
	class CustomWebView;

	class CustomWebPage : public QWebEnginePage
	{
		Q_OBJECT

		CustomWebView * const View_;
        IProxyObject * const BrowserProxy_;
		const ILinkOpenModifier_ptr LinkOpenModifier_;
	public:
		CustomWebPage (IProxyObject*, CustomWebView*);
	protected:
		bool acceptNavigationRequest (const QUrl&, NavigationType, bool) override;
		QWebEnginePage* createWindow (WebWindowType) override;
	signals:
		void webViewCreated (const std::shared_ptr<CustomWebView>&, NewWebViewBehavior::Enum);

        void hookAcceptNavigationRequest (SailmiPIM::IHookProxy_ptr proxy,
				const QUrl& request,
				IWebView *view,
				IWebView::NavigationType type,
				bool isMainFrame);
	};
}
}
